﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using Dataglot;

namespace IrishSettings
{
    public class SelectAllUserSettings:GenericCommand
    {
        public SelectAllUserSettings(DataFactory factory)
            : base(factory)
        {
            const string sql = @"select * from {$ns}_settings_values WHERE
    application= @application 
    AND scope='application'
    AND version= @version ";
            ComposeSql(sql);
            AddParameter("@application", DbType.String);
            AddParameter("@version", DbType.String);
        }

        public DbDataReader Select(
            string application,
            Version version
            )
        {
            if (string.IsNullOrEmpty(application))
                throw new ArgumentException("Missing application name", "application");
            if (version == null)
                throw new ArgumentException("Missing version", "version");

            command.Parameters["@application"].Value = application;
            command.Parameters["@version"].Value = version.ToString();
            return ExecuteReader(CommandBehavior.SingleResult);
        }

    }
}
